# -*- coding:utf-8 -*-
from config import config
from pymongo import MongoClient
from model import queue


def by_regex(mongodb_table_queue):
    regex_array = [
        '^/site/new_publisher$',
        '^/site/new_editor$'
    ]
    mongodb_table_queue.update({"$set": {"status": queue.status_abandon}}, multi=True)


def init_queue(mongodb_db):
    mongodb_collection = mongodb_db[config.mongodb_table_queue]
    data = {
        'url': '/',
        'status': queue.status_add,
        'retry_count': 0
    }
    return mongodb_collection.insert_one(data).inserted_id


def main():
    mongodb_client = MongoClient(config.mongodb_host, config.mongodb_port)
    mongodb_db = mongodb_client[config.mongodb_db]
    mongodb_table_queue = mongodb_db[config.mongodb_table_queue]
    by_regex(mongodb_table_queue)


if __name__ == '__main__':
    main()
